package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.CourseModel;

import java.util.ArrayList;
import java.util.List;

public class CourseUtile {
    FileUtile fileUtile = new FileUtile();
    public List<CourseModel> readCourse(){
        List<CourseModel> courseModels =new ArrayList<>();
        String courseText = fileUtile.readFileToString("CourseFile.txt");
        String[] course =courseText.split(";");
        for (int i=0;i<course.length;i++){
            String item = course[i];
            String[] info = item.split(",");
            CourseModel courseModel =new CourseModel(info[0].trim(),info[1].trim(),info[2].trim(), Double.parseDouble(info[3].trim()),Double.parseDouble(info[4].trim()));
            courseModels.add(courseModel);
        }
        return courseModels;
    }
}
